package com.freak.neteasecloudmusic.modules.find.recommend.base.fragment.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.freak.neteasecloudmusic.R;
import com.freak.neteasecloudmusic.modules.find.recommend.base.fragment.entity.RankingListEntity;

import java.util.List;

public class RankingListAdapter extends BaseQuickAdapter<RankingListEntity.PlaylistBean.TracksBean, BaseViewHolder> {
    private Context context;

    public RankingListAdapter(int layoutResId, @Nullable List<RankingListEntity.PlaylistBean.TracksBean> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RankingListEntity.PlaylistBean.TracksBean item) {
        if (item.getAl() != null) {
            Glide.with(context).load(item.getAl().getPicUrl()).into((ImageView) helper.getView(R.id.imageViewRankingListItemBg));
        }
        helper.setText(R.id.textViewRankingListItemCount, String.valueOf(helper.getAdapterPosition()));

        if (item.getAr() != null && item.getAr().size() > 0) {
            helper.setText(R.id.textViewRankingListItemName, item.getName() + "-" + item.getAr().get(0).getName());
        } else if (item.getAlia() != null && item.getAlia().size() > 0) {
            helper.setText(R.id.textViewRankingListItemName, item.getName() + "-" + item.getAlia().get(0));
        }

    }
}
